<form name="custome">
	<input type="hidden" name="id" value="{$id}">
	<input type="hidden" name="pid" value="{$f_pid}">
	<input type="hidden" name="way" value="{$way}">
	<input type="hidden" name="since" value="{$since}">
	<div class="card_cont">
		<div class="clearboth">
			<div class="card_list w50b float_l">
				<if condition="$data['no_edit'] neq 1">
				<span class="asterisk">*</span><input class="required-text" type="text" name="username" value="{$data['username']}" placeholder="姓名">
				<p class="error-item">必填项</p>
				<else />
				{$data['username']}
				</if>
			</div>
			<div class="card_list w50b float_l" style="border-bottom: 0;">
				<span class="asterisk">*</span><span>性别</span><label <if condition="$data['gender'] eq '男'">class="form_label radio active"<else />class="form_label radio"</if>><input name="gender" value="男" type="radio" <if condition="$data['gender'] eq '男'">checked</if>>男</label><label <if condition="$data['gender'] eq '女'">class="form_label radio active"<else />class="form_label radio"</if>><input name="gender" value="女" type="radio" <if condition="$data['gender'] eq '女'">checked</if>>女</label>
			</div>
		</div>
		<div class="card_list">
			<span class="asterisk">*</span><input class="required-text" type="text" name="company_name" value="{$data['company_name']}" placeholder="公司">
			<p class="error-item">必填项</p>
		</div>
		<div class="card_list">
			<input type="tel" name="mobilephone" value="{$data['mobilephone']}" placeholder="手机（手机号或座机号必须填写一项）">
			<p class="error-item">请填写正确的手机号</p>
		</div>
		<div class="card_list">
			<input type="tel" name="telephone" value="{$data['telephone']}" placeholder="座机（手机号或座机号必须填写一项）">
			<p class="error-item">请填写正确的座机号</p>
		</div>
		<div class="card_list">
			<span class="asterisk">*</span><input id="city" type="text" name="city" tid="{$data['province_id']}" cid="{$data['city_id']}" value="{$data['province']}-{$data['city']}" placeholder="选择省市区" readonly>
		</div>
		<div class="card_list">
			<input type="text" name="address" value="{$data['address']}" placeholder="详细地址（可不填）">
		</div>
		<div class="card_list">
			<input type="text" name="job" value="{$data['job']}" placeholder="职位">
		</div>
		<div class="card_list">
			<input type="email" name="email" value="{$data['email']}" placeholder="邮箱">
			<p class="error-item">请填写正确的邮箱</p>
		</div>
		<div class="card_list">
			<input type="tel" name="qq" value="{$data['qq']}" placeholder="QQ">
			<p class="error-item">请填写正确的QQ</p>
		</div>
		<div class="card_list">
			<input type="text" name="remark" value="{$data['remark']}" placeholder="其他信息">
		</div>
		<button type="button" class="sub_btn card_sub disabled" disabled>提交</button>
	</div>
</form>
<script>
    $(function(){
		submit();
        var init_city_picker = {$caty_arr};
        //选择省市区
        var city_picker = new mui.PopPicker({layer:2});
        city_picker.setData(init_city_picker);
        $("#city").on("click", function(){
            $(this).blur();
            setTimeout(function(){
                city_picker.show(function(items){
                    $("#city").val((items[0] || {}).text + " " + (items[1] || {}).text);
                    $('#city').attr('tid',(items[0] || {}).value);
                    $('#city').attr('cid',(items[1] || {}).value);
                    submit();
                });
            },200);
        });

        $('.radio').click(function(){
            $(this).addClass('active').siblings().removeClass('active');
        })
        $('.card_fix .back_btn').click(function(){
            $('.card_fix').fadeOut().find('.modal_body').html('');
            $('html').removeClass('active')
        })
        $('.card_list label').click(function(){
            submit();
        })
        $("[name='mobilephone']").blur(function(){
            submit();
            var $val = $(this).val();
            if($val!="" && !/^1[3|4|5|7|8]\d{9}$/.test($val)){
                $(this).next(".error-item").show();
            }else{
                $(this).next(".error-item").hide();
            }
        });
        $("[name='telephone']").blur(function(){
            submit();
            var $val = $(this).val();
            if($val!="" && !/^(\d{3,4}\-?)?\d{7,8}(\-\d{3,4})?$/.test($val)){
                $(this).next(".error-item").show();
            }else{
                $(this).next(".error-item").hide();
            }
        });
        $("[name='email']").blur(function(){
            submit();
            var $val = $(this).val();
            if($val!="" && !/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($val)){
                $(this).next(".error-item").show();
            }else{
                $(this).next(".error-item").hide();
            }
        });
        $("[name='qq']").blur(function(){
            submit();
            var $val = $(this).val();
            if($val!="" && !/^[1-9]\d{4,10}$/.test($val)){
                $(this).next(".error-item").show();
            }else{
                $(this).next(".error-item").hide();
            }
        });
        $("[name='username']").blur(function(){
            submit();
            var $val = $(this).val();
            if($val=="" || /^\s+$/.test($val)){
                $(this).next(".error-item").show();
            }else{
                $(this).next(".error-item").hide();
            }
        })
        $("[name='company_name']").blur(function(){
            submit();
            var $val = $(this).val();
            if($val=="" || /^\s+$/.test($val)){
                $(this).next(".error-item").show();
            }else{
                $(this).next(".error-item").hide();
            }
        })
        //提交
        function submit(){
            var tag = true;
            $(".required-text").each(function(){
                var $val = $(this).val();
                if($val=="" || /^\s+$/.test($val)){
                    tag = false;
                }
            });
            if($("[name='mobilephone']").val()=="" && $("[name='telephone']").val()==""){
                tag = false;
            }	
            $("[name='mobilephone']").each(function(){
                var $val = $(this).val();
                if($val!="" && !/^1[3|4|5|7|8]\d{9}$/.test($val)){
                    tag = false;
                }
            });
            $("[name='telephone']").each(function(){
                var $val = $(this).val();
                if($val!="" && !/^(\d{3,4}\-?)?\d{7,8}(\-\d{3,4})?$/.test($val)){
                    tag = false;
                }
            });
            $("[name='email']").each(function(){
                var $val = $(this).val();
                if($val!="" && !/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($val)){
                    tag = false;
                }
            });
            $("[name='qq']").each(function(){
                var $val = $(this).val();
                if($val!="" && !/^[1-9]\d{4,10}$/.test($val)){
                    tag = false;
                }
            });
            if($("[name='gender']:checked").length==0){
                tag = false;
            }
            if($("[name='city']").val()==''){
                tag = false;
            }
            if(tag){
                $('.card_sub').removeClass('disabled').attr('disabled',false);
            }else{
                $('.card_sub').addClass('disabled').attr('disabled',true);
            }
        }
		$('.card_sub').click(function(){
            var tid = $('#city').attr('tid'),
                cid = $('#city').attr('cid'),
                name = $("[name='username']").val();
            $.ajax({
                type:"POST",
                async:false,
                dataType:"json",
                data:$("[name='custome']").serialize()+"&province_id="+tid+"&city_id="+cid,
                url:"__APP__/Mobile/Project/project_card_doedit",
                success:function(data){
                    if(data.status){
						success_pop(data.status,data.msg,1,'__APP__/Mobile/Project/project_bg/id/'+"{$f_pid}");
						/*
                        $('.card_fix').fadeOut().find('.modal_body').html('');
                        $('#name').val(name).attr('uid',data.id);
                        $('#name').attr('py',data.py);
                        $.ajax({
                            type:"POST",
                            async:false,
                            dataType:"json",
                            url:"__APP__/Mobile/Project/project_card_ajax/id/{$f_pid}",
                            success:function(data){
                                provinces = data;
                                $("#name").CityPicker();
                            }
                        });*/
                    }else{
                        modal_alert(data.msg);
                    }
                }
            });
        })
    })
</script>
</body>
</html>